import cv2

def main():
    img = cv2.imread('9/lena_gray.jpg', 0)
    ScharrX = cv2.Scharr(img, cv2.CV_64F, 1, 0)
    ScharrY = cv2.Scharr(img, cv2.CV_64F, 0, 1)
    ScharrX = cv2.convertScaleAbs(ScharrX)
    ScharrY = cv2.convertScaleAbs(ScharrY)
    Scharr = cv2.addWeighted(ScharrX, 0.5, ScharrY, 0.5, 0)
    # Scharr = ScharrX + ScharrY
    cv2.imshow('Scharr', Scharr)
    cv2.waitKey(0)
    cv2.destroyAllWindows()


if __name__ == '__main__':
    main()